package com.training1.core.web.controller;


import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.training1.core.common.controller.BaseController;
import com.training1.core.entity.ContractDetEntity;
import com.training1.core.entity.ContractInfoEntity;
import com.training1.core.modules.service.ContractDetService;
import com.training1.core.modules.service.ContractInfoService;

@Controller
@RequestMapping("contractDet")
public class ContractDetController extends BaseController{
	
	@Resource
	private ContractDetService contractDetService;
	@Resource
	private ContractInfoService contractInfoService;
	
	
	/**
	 * 进入页面
	 * @return
	 */
	@RequestMapping(value={"","/"})
	public String go(String id,Model model){
		
		List<ContractDetEntity> contractExeList = contractDetService.findListById(id);
		ContractInfoEntity contractInfo = contractInfoService.findListById(id);
		if(null != contractExeList && contractInfo != null){
			model.addAttribute("contractExeList",contractExeList);
			model.addAttribute("contractInfo",contractInfo);
		}
		return "contractDet/contractDet";
	}
	
	
	/**
	 * 保存
	 * @param help
	 * @return
	 */
	@RequestMapping(value="save", method={RequestMethod.POST})
	@ResponseBody
	public String  save (String id, String receiveCyc, String receiveDate ,String receiveAmount){
		
		String result= contractDetService.save(id,receiveCyc,receiveDate,receiveAmount);
		
		return result;
	}
	
	
	
	
}
